<?php
/**
 *  Form Interface
 *  Implements ArrayAccess much as Javascript form, ie.
 *      - accessing form[attr] will (which matches first):
 *          - return a form attribute (name,action,renderer,parser etc)
 *          - return an element object, which is otherwise accessible via getElements
 *          - throw an error
 *      - ### NotImpl modifying form[attr] will accordingly set an element, but throw exception if it is not a element object
 *  Form is also iterable over its elements using IteratorAggregate
 *
 */
interface Yz_Form_Interface
{

    /** get all elements
     *  Required, to be able to get an element in those cases when
     *      the element's name is obscured by form's variable e.g. name
     */
    public function getElements();
    public function assignValues(Yz_Item_Interface $item);

    public function render(Yz_Template_Interface $template);

    /**
     *  It would be convenient to throw exception from the parser, but
     *  we require that the parser determine all possible errors before
     *  finishing work.
     *
     *  @return chainable
     *  @throw exception
     */
    public function parse(Yz_Hash $input);


}
